/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2023-05-13
 * Time: 10:26
 */
class Animal{
    public String name;
    public int age;

    public void eat(){
        System.out.println(name+" 正在吃饭！");
    }
}
class Dog extends Animal{
    public void wangwang(){
        System.out.println(name+" 正在汪汪叫！");
    }
}
public class Test2 {
    public static void main(String[] args) {
        /*Animal animal1 = new Dog();
        //向下转型
        Dog dog = (Dog)animal1;
        dog.name = "小黄";
        dog.wangwang();*/


        Animal animal1 = new Dog();
        if(animal1 instanceof Dog){
            //向下转型
            Dog dog = (Dog)animal1;
            dog.name = "小黄";
            dog.wangwang();
        }
    }
}
